/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#include "Logger.h"

namespace XF
{
	Logger* Logger::mInstance = NULL;

	Logger* Logger::GetInstance()
	{
		if(mInstance == NULL)
			mInstance = new Logger();

		return mInstance;
	}

	void Logger::Log(std::string message)
	{
		if(mLogToFile)
		{
			PrintMessageToFile(message);
			//Ogre::LogManager::getSingletonPtr()->logMessage(message);
		}

		OnLogMessage.Invoke(message);
	}

	void Logger::PrintMessageToFile(std::string message)
	{
		mFile << message << "\n";
		//mFile.flush();
	}

	bool Logger::OpenFile(std::string file)
	{
		mFile.open(file.c_str());

		return mFile.is_open();
	}

	void Logger::CloseFile()
	{
		mFile.flush();

		if(mFile.is_open())
			mFile.close();
	}
}
